package com.linuxgt.pattern.adapter.scheme1;

public class Application {
    public static void main(String[] args) {
        ThreeElectrcOutlet outlet;//目标接口（三相插座）
        Wash wash = new Wash();//洗衣机
        outlet = wash;//洗衣机插在三相插座上
        System.out.println("使用三相插座接通电流:");
        outlet.connectElectricCurrent();//接通电源，开始洗衣服
        TV tv = new TV();
        ThreeElectrcAdapter adapter = new ThreeElectrcAdapter(tv);//把电视插在适配器上
        outlet = adapter;
        System.out.println("使用三相插座接通电流:");
        outlet.connectElectricCurrent();//接通电源，开始播放电视节目
    }
}

class Wash implements ThreeElectrcOutlet {//洗衣机使用三相插座
    String name;

    Wash() {
        name = "黄河洗衣机";
    }

    Wash(String s) {
        name = s;
    }

    @Override
    public void connectElectricCurrent() {
        turnOn();
    }

    public void turnOn() {
        System.out.println(name + "开始泳衣物");
    }
}

class TV implements TwoElectrcOutlet {//电视机使用两相插座
    String name;

    TV() {
        name = "长江电视机";
    }

    TV(String s) {
        name = s;
    }

    @Override
    public void connectElectricCurrent() {
        turnOn();
    }

    public void turnOn() {
        System.out.println(name + "开始播放节目。");
    }
}
